<form class="form-horizontal" id="form-add-swiper">
    <input type="hidden" name="aid" value="{$swiper.id}">

    <div class="form-group">
        <label class="control-label col-xs-2">地区<span style="color: #FF0000;">*</span></label>
        <div class="col-xs-9">
            {include file="public/areaSelector" province-name="pro" city-name="city" /}
        </div>
    </div>

    <div class="form-group">
        <label class="control-label col-xs-2">
            类型
            <span style="color: #FF0000;">*</span>
        </label>
        <div class="col-xs-9">
            <select id="category-selector" name="cid" class="form-control" tabindex="-1" required>
                <option value="">
                    无选择
                </option>
                <?php $category_list = get_swiper_category('',2); ?>
                {volist name="category_list" id="item" key="itk"}
                <option {if condition="$swiper.category_id == $itk"}selected{/if} value="{$itk}">{$item}</option>
                {/volist}
            </select>
        </div>
    </div>

    <div class="form-group">
        <label class="control-label col-xs-2">图片<span style="color: #FF0000;">*</span></label>
        <div class="col-xs-9">
            {include file="public/singleImageUploader" uploader-name="thumb" /}
        </div>
    </div>

    <div class="form-group">
        <label class="control-label col-xs-2">链接</label>
        <div class="col-xs-9">
            <input type="text" class="form-control" name="link" value="{$swiper.link}"
                   placeholder="跳转链接">
        </div>
    </div>

    <div class="form-group">
        <label class="control-label col-xs-2">排序</label>
        <div class="col-xs-9">
            <input type="number" class="form-control" name="ord" value="{$swiper.display_order}"
                   placeholder="输入分类序号，序号越高，显示越靠前">
        </div>
    </div>

    <div class="form-group">
        <label class="control-label col-xs-2">是否显示</label>
        <div class="col-xs-9">
            <div class="btn-group" data-toggle="buttons">
                <label class="btn btn-default {if condition='$swiper.is_visible'}active{/if}">
                    <input type="radio" name="visible" id="visible_1" value="1" {if condition="$swiper.is_visible"}checked{/if}> 显示
                </label>
                <label class="btn btn-default {if condition='!$swiper.is_visible'}active{/if}">
                    <input type="radio" name="visible" id="visible_0" value="0" {if condition="!$swiper.is_visible"}checked{/if}> 隐藏
                </label>
            </div>
        </div>
    </div>

    <div class="form-group">
        <div class="col-xs-offset-2 col-xs-3">
            <button type="submit" class="btn btn-success btn-block">确认修改</button>
        </div>
    </div>
</form>

<script src="__PUBLIC__/vendors/jquery.validation/jquery.validate.min.js"></script>
<script src="__PUBLIC__/vendors/jquery.validation/additional-methods.js"></script>
<script src="__PUBLIC__/vendors/jquery.validation/messages_zh.min.js"></script>
<script src="__PUBLIC__/vendors/select2/js/select2.min.js"></script>
<script type="application/javascript">
    $(function () {
        $("#form-add-swiper").validate({
            messages:
                {
                    cid: "请选择轮播类型",
                },
            debug: true,
            submitHandler: function () {
                ajaxSubmit('form-add-swiper', true);
            }
        });
        //获取分类
        $("#category-selector").select2({
            placeholder: "选择轮播类型",
            allowClear: true
        });
    })
</script>